package com.mouse.hadoop.explorer.pojo;

import org.apache.hadoop.fs.FileStatus;

/**
 * Created by cwx183898 on 2017/7/13.
 */
public class FileStatusModel {
    private FileStatus fs;

    public FileStatusModel(FileStatus fs) {
        this.fs = fs;
    }

    public String getId() {
        return this.getPath();
    }

    public String getPath() {
        return fs.getPath().toString();
    }

    public Long getModificationTime() {
        return fs.getModificationTime();
    }

    public String getOwner() {
        return fs.getOwner();
    }

    public String getGroup() {
        return fs.getGroup();
    }

    public Boolean isDirectory() {
        return fs.isDirectory();
    }

    public Boolean isFile() {
        return fs.isFile();
    }

    public Boolean isEncrypted() {
        return fs.isEncrypted();
    }


    public Long getAccessTime() {
        return fs.getAccessTime();
    }

    public Long getSize() {
        return fs.getLen();
    }

    public String getName() {
        String path = this.getPath();
        int lastIndex = path.lastIndexOf("/");
        return path.substring(lastIndex + 1, path.length());
    }

    public boolean isLeaf() {
        return !fs.isDirectory();
    }
}
